﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
  xmlns:inputToolkit="clr-namespace:System.Windows.Controls">

  <Style TargetType="inputToolkit:DomainUpDown">
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Height" Value="22"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Padding" Value="0"/>
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="BorderBrush">
      <Setter.Value>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FFA3AEB9" Offset="0"/>
          <GradientStop Color="#FF8399A9" Offset="0.375"/>
          <GradientStop Color="#FF718597" Offset="0.375"/>
          <GradientStop Color="#FF617584" Offset="1"/>
        </LinearGradientBrush>
      </Setter.Value>
    </Setter>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="inputToolkit:DomainUpDown">
          <Grid x:Name="RootElement">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- common states -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="Pressed"/>
                <vsm:VisualState x:Name="MouseOver">
                 <!-- composite controls will visualize mouseover state -->
                </vsm:VisualState>
                <vsm:VisualState x:Name="Disabled">
                  <!-- composite controls will visualize disabled state -->
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- focus states -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <!-- composite controls will gain focus and visualize it -->
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused">
                  <!-- composite controls will gain focus and visualize it -->
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- interaction mode states -->
              <vsm:VisualStateGroup x:Name="InteractionModeStates">
                <vsm:VisualState x:Name="Edit">
                  <Storyboard>
                    <DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Text" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="1"/>
                    <DoubleAnimation 
                      Duration="0" 
                      Storyboard.TargetName="Visualization" 
                      Storyboard.TargetProperty="(UIElement.Opacity)" 
                      To="0"/>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Display" />
              </vsm:VisualStateGroup>
              <!-- input valid states -->
              <vsm:VisualStateGroup x:Name="DomainStates">
                <vsm:VisualState x:Name="ValidDomain">
                </vsm:VisualState>
                <vsm:VisualState x:Name="InvalidDomain">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames 
                      Storyboard.TargetName="ErrorVisualElement" 
                      Storyboard.TargetProperty="(UIElement.Visibility)" 
                      Duration="0">
                      <DiscreteObjectKeyFrame 
                        KeyTime="0" 
                        Value="Visible" />
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>
            <!-- the actual control -->
            <inputToolkit:ButtonSpinner
              x:Name="Spinner"
              Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}" 
              BorderThickness="{TemplateBinding BorderThickness}" 
              Padding="{TemplateBinding Padding}"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              HorizontalContentAlignment="Stretch"
              VerticalContentAlignment="Stretch"
              Style="{TemplateBinding SpinnerStyle}"
              IsTabStop="False"
              TabIndex="3">
              <Grid>
                <ContentControl
                  x:Name="Visualization"
                  Margin="0" 
                  Padding="0"
                  Opacity="1"
                  IsTabStop="False"
                  IsHitTestVisible="False"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                  Content="{TemplateBinding Value}"
                  ContentTemplate="{TemplateBinding ItemTemplate}"
                  FontFamily="{TemplateBinding FontFamily}"
                  FontSize="{TemplateBinding FontSize}"
                  FontStretch="{TemplateBinding FontStretch}"
                  Foreground="{TemplateBinding Foreground}" />
                <TextBox 
                  x:Name="Text" 
                  Opacity="0" 
                  Margin="0" 
                  Padding="0"
                  IsTabStop="True"
                  Background="Red"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  BorderThickness="0"
                  FontFamily="{TemplateBinding FontFamily}"
                  FontSize="{TemplateBinding FontSize}"
                  FontStretch="{TemplateBinding FontStretch}"
                  Foreground="{TemplateBinding Foreground}"
                  AcceptsReturn="False" 
                  IsHitTestVisible="False"
                  TextWrapping="NoWrap" >
                  <TextBox.Style>
                    <Style TargetType="TextBox">
                      <Setter Property="Template">
                        <Setter.Value>
                          <ControlTemplate TargetType="TextBox">
                            <ScrollViewer
                              x:Name="ContentElement"
                              Padding="0"
                              BorderThickness="0" />
                          </ControlTemplate>
                        </Setter.Value>
                      </Setter>
                    </Style>
                  </TextBox.Style>
                </TextBox>
              </Grid>
          </inputToolkit:ButtonSpinner>
            <Border
              x:Name="ErrorVisualElement"
              CornerRadius="1"
              Visibility="Collapsed"
              Margin="-2"
              IsHitTestVisible="False"
              BorderBrush="Red"
              BorderThickness="2" />
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>